package com.hhkj.sms.common.template;

import com.alibaba.fastjson2.JSONObject;
import com.hhkj.sms.model.AliDaYuParam;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * AliDaYuTemplate
 *
 * @author HHKJ-SERVER-ZJ
 * @since 2023/10/24 16:27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component
@ConfigurationProperties(prefix = "aliyun.sms")
public class AliDaYuTemplate {

    /** 短信签名名称 */
    private String signName;

    /** 短信模板CODE */
    private String templateCode;

    public AliDaYuParam createSmsBody(String templateParam) {
        return new AliDaYuParam(this.signName, this.templateCode, templateParam);
    }

    public AliDaYuParam createSmsBody(Object object) {
        String templateParam = JSONObject.toJSONString(object);
        return this.createSmsBody(templateParam);
    }
}
